class Solution9 {
    public long prev = Long.MIN_VALUE;    
    public boolean tf = true;
    public boolean isValidBST(TreeNode root) {
        if(root == null) return true;
        boolean left = isValidBST(root.left);
        if(prev >= root.val) {
            tf = false;
            return tf;
        }else {
            prev = root.val;
        }
        boolean right = isValidBST(root.right);
        return tf;
    }
}